# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=fxc2
pkgbase=mingw-w64-${_realname}-git
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=r15.5ace4c2
_commit='5ace4c25b63cb5a83b58a3eae3d36256a6022cde'
pkgrel=1
pkgdesc="A wine-runnable version of Microsofts Shader Compiler fxc (mingw-w64)"
arch=('any')
url='https://github.com/mozilla/fxc2/'
license=('custom:Mozilla')
options=('strip' 'staticlibs')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "git")
source=(${_realname}::git+"https://github.com/mozilla/fxc2.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count $_commit)" "$(git rev-parse --short $_commit)"
}

prepare() {
  cd "${srcdir}"/${_realname}
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  cp -rf ${_realname} build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ${MINGW_PREFIX}/bin/g++ -static fxc2.cpp -o fxc.exe
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/bin
  cp fxc.exe ${pkgdir}${MINGW_PREFIX}/bin/
}
